package com.example.agriapp.view.activity;

import android.os.Bundle;
import android.widget.ListView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import com.example.agriapp.R;
import com.example.agriapp.data.SettingItem;
import com.example.agriapp.adapter.SettingAdapter;

import java.util.ArrayList;
import java.util.List;

public class SettingActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.bottom_nav_icon_selected));
        // 初始化返回按钮
        findViewById(R.id.backButton).setOnClickListener(v -> finish());

        // 准备设置项数据
        List<SettingItem> settings = new ArrayList<>();
        settings.add(new SettingItem("个人信息", ""));
        settings.add(new SettingItem("实名认证", "未实名"));
        settings.add(new SettingItem("专家认证", ""));
        settings.add(new SettingItem("地址管理", ""));
        settings.add(new SettingItem("隐私设置", ""));
        settings.add(new SettingItem("登录密码", "修改"));
        settings.add(new SettingItem("提现密码", "修改"));
        settings.add(new SettingItem("联系客服", ""));
        settings.add(new SettingItem("意见反馈", ""));
        settings.add(new SettingItem("关于我们", ""));
        settings.add(new SettingItem("隐私政策", ""));
        settings.add(new SettingItem("用户协议", ""));
        settings.add(new SettingItem("检查更新", ""));

        // 设置适配器
        ListView listView = findViewById(R.id.settingsList);
        SettingAdapter adapter = new SettingAdapter(this, settings);
        listView.setAdapter(adapter);

        // 设置点击事件
        listView.setOnItemClickListener((parent, view, position, id) -> {
            SettingItem item = settings.get(position);
            handleSettingClick(item);
        });
    }

    private void handleSettingClick(SettingItem item) {
        switch (item.getTitle()) {
//            case "个人信息":
//                startActivity(new Intent(this, ProfileActivity.class));
//                break;
//            case "实名认证":
//                startActivity(new Intent(this, RealNameAuthActivity.class));
//                break;
//            case "登录密码":
//                startActivity(new Intent(this, ChangePasswordActivity.class));
//                break;
            // 其他选项处理...
            default:
                Toast.makeText(this, item.getTitle(), Toast.LENGTH_SHORT).show();
        }
    }
}